package com.zyd.recyclerviewdemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zyd.recyclerviewdemo.R;

import java.util.List;

public class MyListViewAdapter extends BaseAdapter {
    private List<String> dataList;
    private LayoutInflater inflater;
    public MyListViewAdapter(List<String> dataList, Context context) {
        this.dataList = dataList;
        this.inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public String getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //加载布局为一个视图
        View view=inflater.inflate(R.layout.adapter_load_more,null);
        String content =getItem(position);
        TextView text = view.findViewById(R.id.tv_item);
        text.setText(content);
        return view;
    }
}
